#ifndef QTAV_AVDECODER_P_H
#define QTAV_AVDECODER_P_H

#include <QtCore/QByteArray>
#include <QtCore/QMutex>
#include <QtCore/QThread>
#include <QtAV/QtAV_Compat.h>

namespace QtAV {

class Q_AV_EXPORT AVDecoderPrivate : public DPtrPrivate<AVDecoder>
{
public:
    AVDecoderPrivate():
        codec_ctx(0)
      , available(true)
      , fast(false)
      , is_open(false)
      , frame(0)
      , got_frame_ptr(0)
      , thread_slice(1)
      , low_resolution(0)
    {
        frame = avcodec_alloc_frame();
        threads = qMax(0, QThread::idealThreadCount()); //av_cpu_count is not available for old ffmpeg. c++11 thread::hardware_concurrency()
    }
    virtual ~AVDecoderPrivate() {
        if (frame) {
            av_free(frame);
            frame = 0;
        }
    }

    AVCodecContext *codec_ctx; //set once and not change
    bool available;
    bool fast;
    bool is_open;
    AVFrame *frame; //set once and not change
    QByteArray decoded;
    int got_frame_ptr;
    QMutex mutex;
    int threads;
    bool thread_slice;
    int low_resolution;
    QString name;
};

} //namespace QtAV
#endif // QTAV_AVDECODER_P_H
